package com.zerox.service.impl;

import com.zerox.mapper.SysUserMapper;
import com.zerox.pojo.SysUser;
import com.zerox.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author
 * @version V1.11
 * @ClassName:
 * @Description:
 * @Date
 */
@Service
public class SysUserServiceImpl implements SysUserService {

    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public SysUser login(String username, String password) {
        SysUser sysUser = sysUserMapper.selectByUser(username);
        if(sysUser!=null){
            if (sysUser.getPassword().equals(password)) {
                return sysUser;
            }
        }
        return null;
    }

    @Override
    public List<SysUser> list(Integer page, Integer limit, String realName, Integer roleId) {
        Integer startIndex=(page-1)*limit;
        return sysUserMapper.list(startIndex,limit,realName,roleId);
    }

    @Override
    public int count(String realName, Integer roleId) {
        return sysUserMapper.count(realName,roleId);
    }
    
    @Override
    public SysUser selectId(String id) {
        return sysUserMapper.selectId(id);
    }
    
    @Override
    public Integer update(SysUser sysUser) {
        return sysUserMapper.update(sysUser);
    }
    
    public SysUserServiceImpl(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }
}
